$INCLUDE: 'C:\FG\FASTGRAF.FI'

      PROGRAM MAIN

      INTEGER PAGES
      PARAMETER (PAGES=4)

      INTEGER OLD_MODE, NEW_MODE
      INTEGER PAGE
      INTEGER STATUS
      CHARACTER*6 STRING
      INTEGER FG_ALLOCATE, FG_FREEPAGE
      INTEGER FG_BESTMODE, FG_GETMAXX, FG_GETMAXY, FG_GETMODE

      CALL FG_INITPM
      NEW_MODE = FG_BESTMODE(80,25,PAGES)
      IF (NEW_MODE .LT. 0) THEN
         STOP 'This program requires an 80-column display.'
      END IF

      OLD_MODE = FG_GETMODE()
      CALL FG_SETMODE(NEW_MODE)
      CALL FG_CURSOR(0)

      DO 10 PAGE = 0,PAGES-1
         STATUS = FG_ALLOCATE(PAGE)
         CALL FG_SETPAGE(PAGE)
         CALL FG_SETCOLOR(7)
         CALL FG_RECT(0,FG_GETMAXX(),0,FG_GETMAXY())
         CALL FG_SETATTR(0,7,0)
         CALL FG_LOCATE(12,37)
         WRITE(STRING,1000) PAGE
         CALL FG_TEXT(STRING,6)
10    CONTINUE

      DO 20 PAGE = 0,PAGES-1
         CALL FG_SETVPAGE(PAGE)
         CALL FG_WAITKEY
         STATUS = FG_FREEPAGE(PAGE)
20    CONTINUE

      CALL FG_SETMODE(OLD_MODE)
      CALL FG_RESET

      STOP ' '
1000  FORMAT('page',I2)
      END
